package com.tencent.wxcloudrun.controller;

import com.tencent.wxcloudrun.model.Shop;
import com.tencent.wxcloudrun.model.ShopListReq;
import com.tencent.wxcloudrun.response.R;
import com.tencent.wxcloudrun.service.ShopService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName: ShopController
 * Package: com.tencent.wxcloudrun.controller
 * Description:
 *
 * @Date: 2023/1/22 8:34 AM
 * @Author: wht
 */
@Slf4j
@RestController
//@RestController = @Controller + @ResponseBody
@RequestMapping("/admin")
public class ShopController {
    @Autowired
    ShopService shopService;

    @PutMapping("/addOneShop")
    public <T> R<T> addOneShop(@RequestBody Shop shop) {
        shopService.addOneShop(shop);
        return R.successMsg("添加成功！");
    }

    @PatchMapping("/updateOneShopById")
    public <T> R<T> updateOneShopById(@RequestBody Shop shop) {
        shopService.updateOneShopById(shop);
        return R.successMsg("修改成功！");
    }


    @PostMapping("/getShopList")
    public <T> R<T> getShopList(@RequestBody ShopListReq shop) {
        List<Shop> shops = shopService.getShopList(shop);
        return R.successData(shops);
    }


}
